<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>标签管理</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script>
    <script src="https://unpkg.com/vue@2.7.16/dist/vue.min.js"></script>
    <script src="/static/js/axios.js"></script>
    <script src="/static/js/server.js"></script>
    <script src="/static/js/tools.js"></script>
    <script src="/static/js/qs.js"></script>
</head>

<body>
    <div id="app">
        <div class="container col-md-3 mt-5">
            <div class="py-4">
                <h2>账号注册</h2>
                <div class="row mb-3">
                    <div class="col">
                        <label class="form-label">昵称:</label>
                        <input type="text" class="form-control" id="created_by" v-model="userInfo.nikename" />
                    </div>
                </div>
                <div class="mb-3">
                    <label class="form-label">账号名称:</label>
                    <input type="text" class="form-control" id="title" v-model="userInfo.account" />
                </div>
                <div class="row mb-3">
                    <div class="col">
                        <label class="form-label">密码:</label>
                        <input type="password" class="form-control" id="created_by" v-model="userInfo.password" />
                    </div>
                </div>

                <div class="d-flex flex-column justify-content-between align-items-center">
                    <button class="btn btn-primary" @click="register">注册</button>
                    <a class="mt-3" href="/app/view/login.html">已有账号,前去登陆</a>
                </div>
            </div>
        </div>

    </div>
</body>
<script>
    var vue = new Vue({
        el: '#app',
        data: {
            userInfo: {
                account: "",
                nikename: "",
                password: ""
            },
        },
        created() {

        },
        methods: {
            register() {
                if (this.userInfo.account == "") {
                    alert("账号不能为空");
                    return;
                }
                axios.post('http://127.0.0.1:8001/user/register', this.userInfo).then(res => {
                    console.log(res)
                    if (res.code != 200) {
                        console.log(res.msg)
                        return;
                    }
                    alert("注册成功");
                    location.href = "/app/view/login.html";
                })
            }
        },

    })
</script>

</html>